package com.ggb.reactive.converter
import org.springframework.core.convert.converter.Converter
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter

object StringToInstantConverter : Converter<String, Instant> {
    private val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")

    override fun convert(source: String): Instant? =
        LocalDateTime.parse(source, formatter).toInstant(ZoneOffset.UTC)
}
